
//BrowserName
function browserName(){
	var ua = window.navigator.userAgent;
	if(ua.indexOf("MSIE")>-1 || ua.indexOf(".NET")>-1) return "MSIE";
	else if(ua.indexOf("Edge")>-1) return "Edge";
	else if(ua.indexOf("Firefox")>-1) return "Firefox";
	else if(ua.indexOf("Chrome")>-1) return "Chrome";
	else if(ua.indexOf("Safari")>-1) return "Safari";
	else if(ua.indexOf("Opera")>-1) return "Opera";
	else if(ua.indexOf("QQBrowser")>-1) return "QQBrowser";
	else return "other";
}

//return current date yyyy-MM-dd
function getNowDate(){
	var date = new Date();
	var year = date.getFullYear();
	var month = date.getMonth()+1;
	var day = date.getDate();
	month = month.toString().length==1?"0"+month:month;
	day = day.toString().length==1?"0"+day:day;
	return year+"-"+month+"-"+day;
}

//return current time HH:mm:ss
function getNowTime(){
	var date = new Date();
	var hour = date.getHours();
	var minute = date.getMinutes();
	var second = date.getSeconds();
	hour = hour.toString().length==1?"0"+hour:hour;
	minute = minute.toString().length==1?"0"+minute:minute;
	second = second.toString().length==1?"0"+second:second;
	return hour+":"+minute+":"+second;
}

//return current full yyyy-MM-dd HH:mm:ss
function getNowFull(){
	var date = new Date();
	var year = date.getFullYear();
	var month = date.getMonth()+1;
	var day = date.getDate();
	var hour = date.getHours();
	var minute = date.getMinutes();
	var second = date.getSeconds();
	month = month.toString().length==1?"0"+month:month;
	day = day.toString().length==1?"0"+day:day;
	hour = hour.toString().length==1?"0"+hour:hour;
	minute = minute.toString().length==1?"0"+minute:minute;
	second = second.toString().length==1?"0"+second:second;
	return year+"-"+month+"-"+day+" "+hour+":"+minute+":"+second;
}

//return current unformated date yyyyMMddHHmmss
function getNowUFDate(){
	var str = getNowFull();
	str = str.replace(/-/g, "");
	str = str.replace(/:/g, "");
	str = str.replace(/\s/g, "");
	return str;
}

//return week day in CN type
function getNowWeekCN(){
	var week = {'0':'星期天','1':'星期一','2':'星期二','3':'星期三','4':'星期四','5':'星期五','6':'星期六'};
	var day = new Date().getUTCDay();
	return week[day];
}

//replace the str's oldSubStr with newSubStr
function replace(str, oldSubStr, newSubStr){
	var re = new RegExp(oldSubStr, "g");
	str = str.replace(re, newSubStr);
	return str;
}
